package com.fanhao.dllo.justforyou.factory;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.SparseArray;

import com.fanhao.dllo.justforyou.fragment.JokeMessageFragment;
import com.fanhao.dllo.justforyou.fragment.JokePictureFragment;

/**
 * Created by dllo on 15/10/23.
 */
public class JokeFragmentFactory {

    private static SparseArray<Fragment> fragmentMap = new SparseArray<>();

    public static Fragment createFragment(int position) {
        Fragment f = fragmentMap.get(position);
        if (f == null) {
            switch (position) {
                case 0:
                    f = new JokeMessageFragment();
//                    Bundle args0 = new Bundle();
//                    args0.putInt("position", position);
//                    f.setArguments(args0);

                    break;
                case 1:
                    f = new JokePictureFragment();
//                    Bundle args1 = new Bundle();
//                    args1.putInt("position",position);
//                    f.setArguments(args1);

                    break;
            }
            fragmentMap.put(position,f);
        }
        return f;
    }
}
